<?php
/**************************************************
* PluginLotto.com                                 *
* Copyrights (c) 2005-2010. iZAP                  *
* All rights reserved                             *
***************************************************
* @author iZAP Team "<support@izap.in>"
* @link http://www.izap.in/
* @version 1.0
* Under this agreement, No one has rights to sell this script further.
* For more information. Contact "Tarun Jangra<tarun@izap.in>"
* For discussion about corresponding plugins, visit http://www.pluginlotto.com/pg/forums/
* Follow us on http://facebook.com/PluginLotto and http://twitter.com/PluginLotto
*/

$entity = $vars['entity'];
if(!$entity) {
  return '';
}
$entity->try_end_auction();
$owner = $entity->getOwnerEntity();
?>
<div class="contentWrapper">

  <?php if($vars['remove_icon'] !== TRUE) {?>
  <div class="listing-image">
    <a href="<?php echo $entity->getUrl()?>">
      <img src="<?php echo $entity->getIcon();?>" alt="<?php echo $entity->title?>" align="left" width="100" height="100"/>
    </a>
  </div>
    <?php } ?>

  <div class="listing-description">
    <h3>
      <a href="<?php echo $entity->getUrl();?>">
        <?php echo $entity->title;?>
      </a>
    </h3>
    <p align="justify">
      <?php
      echo substr(filter_var($entity->description, FILTER_SANITIZE_STRING), 0, 200);
      ?>
    </p>
  </div>

  <div class="listing-options">
    <?php
    echo elgg_view('output/rate', array('entity' => $entity));
    $total_views = func_get_views_byizap($entity);
    $total_comments = elgg_count_comments($entity);
    if($total_views) {
      ?>
    <b><?php echo elgg_echo('izap_offer_article:total_views') ;?>: </b> <?php echo $total_views?><br />
      <?php
    }
    ?>
    <b>
      By:
    </b>
    <a href="<?php echo $owner->getURL();?>">
      <?php
      echo $owner->name;
      ?>
    </a>
    <br />
    <?php if($total_comments) {?>
    <b>
      Comments(<?php echo $total_comments;?>)
    </b>
    <br />
      <?php }?>
    <?php
    if($vars['entity']->isItemOpen()) {
      if($vars['entity']->status===1) {
        ?>
        <b><?php echo elgg_echo('izap_offer_article:timeleft');?></b><br />
        <?php echo $vars['entity']->getRemainingTime();?><br />
      <?php
      }
      ?>
      <b>Current bid: </b><?php echo $vars['entity']->displayHighestBid() ;?> <br />

    <?php
    }
    if($vars['entity']->is_closed_item()) {
      ?>
      <b>Winner: </b><a href="<?php echo $vars['entity']->get_winner()->getURL() ;?>"><?php echo $vars['entity']->get_winner()->name ;?></a> <br />
    <?php
    }
    ?>

    <?php
    if($vars['entity']->canEdit()) {

      if($vars['entity']->status===0 && $vars['entity']->expire_date>CURRENT_TIMESTAMP) {
        echo elgg_view("output/confirmlink", array(
                'href' => func_get_actions_path_byizap()."payfee?guid=" . $vars['entity']->guid . "",
                'text' => elgg_echo('izap_offer_article:payauctionfee'),
                'confirm' => elgg_echo('izap_offer_article:payauctionfee_confirm'),
        )) . ' / ';
      }

      if($vars['entity']->isItemOpen()) {
        echo elgg_view("output/confirmlink", array(
                'href' => func_get_actions_path_byizap()."close?guid=" . $vars['entity']->guid . "",
                'text' => elgg_echo('izap_offer_article:endauction'),
                'confirm' => elgg_echo('izap_offer_article:endauction_confirm'),
        )) . ' / ';
      }

       if($vars['entity']->can_edit_auction()) :
    ?>
    
      <a href="<?php echo func_get_www_path_byizap(array('type'=>"page")).'save/'.$vars['entity']->guid; ?>">Edit</a> /
      <?php

        echo elgg_view("output/confirmlink", array(
                'href' => func_get_actions_path_byizap()."delete?guid=" . $vars['entity']->guid . "",
                'text' => elgg_echo('delete'),
                'confirm' => elgg_echo('deleteconfirm'),
        ));
      endif;
    }
    ?>
  </div>

  <div class="clearfloat"></div>
  <p>
    <?php
    //echo '<img src="'.func_get_www_path_byizap(array('type' => 'images', 'plugin' => 'izap-skin')).'tag.gif" alt="Tags"/>';
    echo '<img src="'.$vars['url'].'_graphics/icon_tag.gif" alt="Tags"/>';
    echo elgg_view('output/tags', array('tags' => $entity->tags));
    ?>
  </p>

  <?php
    if($vars['entity']->status===0 && $vars['entity']->expire_date>CURRENT_TIMESTAMP) {
        echo '<p>Auction has pending fee of '.CURRENCY_SYMBOL . $vars['entity']->auction_fee.', click ' . elgg_view("output/confirmlink", array(
                'href' => func_get_actions_path_byizap()."payfee?guid=" . $vars['entity']->guid . "",
                'text' => "here",
                'confirm' => elgg_echo('izap_offer_article:payauctionfee_confirm'),
        )) . ' to continue.</p>';
      }
    ?>
</div>

